import React from "react";
import { Consumer } from "./Context.js";
class CreateContextGrandSon extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
        childChild
        <Consumer>
          {(user) => {
            console.log(user);
            return (
              <div
                style={{
                  border: "1px solid green",
                  padding: "8px",
                }}
              >
                <p>
                  孙子组件。获取传递下来的值:{user.name}|age:{user.age}
                  <button
                    onClick={() => {
                      user.grow();
                    }}
                  >
                    Grow
                  </button>
                </p>
              </div>
            );
          }}
        </Consumer>
      </div>
    );
  }
}
export default CreateContextGrandSon;
